﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

using System.IO;
using System.Net;
using System.Data;
using System.Data.SqlClient;

namespace Trade.DBUtility
{
    #region 自定义表信息
    /// <summary>
    /// 邮件信息
    /// </summary>
    [Serializable]
    public class DataTableName
    {
        public DataTableName()
        { }
        /// <summary>
        /// 表名
        /// </summary>
        public string strTableName = string.Empty;
        /// <summary>
        /// 得到数据的SQL语句
        /// </summary>
        public string strSelectSQL = string.Empty;
        /// <summary>
        /// 得到数据的SQL参数
        /// </summary>
        public List<SqlParameter> SqlSelectParameterList = new List<SqlParameter>();
        /// <summary>
        /// 不赋值,得到数据的SQL参数
        /// </summary>
        public List<SerSqlParameter> SerSqlSelectParameterList = new List<SerSqlParameter>();
        /// <summary>
        /// 执行的SQL
        /// </summary>
        public string strExecSQL = string.Empty;
        /// <summary>
        /// 执行的SQL参数
        /// </summary>
        public List<SqlParameter> SqlExecParameterList = new List<SqlParameter>();
        /// <summary>
        /// 不赋值,执行的SQL参数
        /// </summary>
        public List<SerSqlParameter> SerSqlExecParameterList = new List<SerSqlParameter>();
        /// <summary>
        /// 执行(比如删除)数据后所执行的SQL语句,当然也可以写触发器
        /// </summary>
        public List<ExecAfterSQL> ExecAfterSQLList = new List<ExecAfterSQL>();
        #region 执行(比如删除)数据后所执行的SQL语句
        /// <summary>
        /// 执行(比如删除)数据后所执行的SQL语句,当然也可以写触发器
        /// </summary>
        [Serializable]
        public class ExecAfterSQL
        {
            public ExecAfterSQL()
            { }
            /// <summary>
            /// 删除数据后所执行的SQL语句
            /// </summary>
            public string strSQL = string.Empty;
            /// <summary>
            /// 删除数据后所执行的SQL参数
            /// </summary>
            public List<SqlParameter> SqlParameterList = new List<SqlParameter>();
            /// <summary>
            /// 不赋值,删除数据后所执行的SQL参数
            /// </summary>
            public List<SerSqlParameter> SerSqlParameterList = new List<SerSqlParameter>();
        }
        #endregion
        /// <summary>
        /// 是否存在的SQL
        /// </summary>
        public string strIsExistsSQL = string.Empty;
        /// <summary>
        ///是否存在的SQL参数
        /// </summary>
        public List<SqlParameter> SqlIsExistsParameterList = new List<SqlParameter>();
        /// <summary>
        ///不赋值,是否存在的SQL参数
        /// </summary>
        public List<SerSqlParameter> SerSqlIsExistsParameterList = new List<SerSqlParameter>();
        /// <summary>
        /// 保存的SQL语句
        /// </summary>
        public string strSaveSQL = string.Empty;
        /// <summary>
        /// 保存数据后所执行的SQL语句,当然也可以写触发器
        /// </summary>
        public List<SaveAfterSQL> SaveAfterSQLList = new List<SaveAfterSQL>();
        #region 保存数据后所执行的SQL语句
        /// <summary>
        /// 保存数据后所执行的SQL语句,当然也可以写触发器
        /// </summary>
        [Serializable]
        public class SaveAfterSQL
        {
            public SaveAfterSQL()
            { }
            /// <summary>
            /// 保存数据后所执行的SQL语句
            /// </summary>
            public string strSQL = string.Empty;
            /// <summary>
            /// 保存数据后所执行的SQL参数
            /// </summary>
            public List<SqlParameter> SqlParameterList = new List<SqlParameter>();
            /// <summary>
            /// 不赋值,保存数据后所执行的SQL参数
            /// </summary>
            public List<SerSqlParameter> SerSqlParameterList = new List<SerSqlParameter>();
        }
        #endregion
        [Serializable]
        public class SerSqlParameter
        {
            public SerSqlParameter(SqlParameter sPara)
            {
                this.paraName = sPara.ParameterName;
                this.paraLen = sPara.Size;
                this.paraVal = sPara.Value;
                this.sqlDbType = sPara.SqlDbType;
            }

            public SqlParameter ToSqlParameter()
            {
                SqlParameter para = new SqlParameter(this.paraName, this.sqlDbType, this.paraLen);
                para.Value = this.paraVal;
                return para;
            }

            private string paraName = "";
            public string ParaName
            {
                get { return this.paraName; }
                set { this.paraName = value; }

            }

            private int paraLen = 0;
            public int ParaLen
            {

                get { return this.paraLen; }
                set { this.paraLen = value; }
            }

            private object paraVal = null;
            public object ParaVal
            {
                get { return this.paraVal; }
                set { this.paraVal = value; }
            }

            private SqlDbType sqlDbType = SqlDbType.NVarChar;
            public System.Data.SqlDbType SqlDbType
            {
                get { return this.sqlDbType; }

                set { this.sqlDbType = value; }
            }
        }
    }
    #endregion
}
